<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>登录</title>
<link rel="stylesheet" href="/css/index.css" type="text/css">
<script type="text/javascript" src="/js/jquery-3.5.1.min.js"></script>
</head>
<body>
   <div class="login">
   		<h3>山东省儿童青少年近视防控大数据平台</h3>
		<div class="LGtxt">
			<div class="Boxex">
				<form id="Form" method="post" action="/login">
				<div class="Atxt">
					<em></em>
					<input id="username" type="text" name="username" placeholder="账号" />
				</div>
				<div class="Atxt Btxt">
					<em></em>
					<input id="password" type="password" name="password" placeholder="密码" />
				</div>
					<input id="choseType" name="choseType" value="政府部门" hidden="hidden">
				<input type="button" class="loginBtn" value="登录" />
				</form>
				<ul class="choseBtn">
					<li class="on" ><span>政府<br/>部门</span></li>
					<li ><span>医疗<br/>机构</span></li>
					<li ><span>学校</span></li>
					<li ><span>家庭<br/>个人</span></li>
				</ul>
			</div>
		</div>
   </div>
</body>
</html>

<script type="text/javascript">
	// var choseType = 'zhengfu';
	$(".choseBtn li").click(function(){
		$(this).addClass("on").siblings().removeClass("on")
		$("#choseType").val($(this).text());
		if ($(this).text()=='家庭个人'){
			document.getElementById("Form").setAttribute("action","/loginForPerson")
			document.getElementById("username").setAttribute("placeholder","姓名")
			document.getElementById("password").setAttribute("placeholder","身份证号")
		}
		if ($(this).text()!='家庭个人'){
			document.getElementById("Form").setAttribute("action","/login")
			document.getElementById("username").setAttribute("placeholder","账号")
			document.getElementById("password").setAttribute("placeholder","密码")
		}
	});
	$(".loginBtn").on('click',function (){
/*
		$("#Form").submit();
*/
		var loginUrl = $("#Form").attr("action");
		var data = $("#Form").serialize();
		$.ajax({
			type:'post',
			url:loginUrl,
			cache:false,
			data:data,
			datatype:'json',
			success:function (R){
				if (R.code==0){
					location.href=R.url;
				}else {
					alert(R.msg);
				}
			},
			error:function (R){
				alert('服务器繁忙，请稍后再试')
			}
		})
	});
</script>


